var SelectDivision = 
'<div class="modal" id="SelectDivision" tabindex="-1" role="dialog" aria-hidden="true">'+
	'<div class="modal-dialog" style="width: 800px !important;">'+
		'<div class="modal-content">'+
			'<div class="modal-header">'+
				'<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>'+
				'<h4 class="modal-title">选择产地</h4>'+
				'<div class="form-box2">'+
					'<div class="have-ipt-box">'+
						'<label class="ipt-label" for="">产地编码：</label>'+
						'<input class="ipt-self1" type="text" name="code" id="dCode" value="" />'+
					'</div>'+
					'<div class="have-ipt-box">'+
						'<label class="ipt-label" for="">产地名称：</label>'+
						'<input class="ipt-self1" type="text" name="name" id="dName" value="" />'+
					'</div>'+
					'<div class="form-btn-box form-btn-box2">'+
						'<button class="btn-blue" id="division-selectBtn">'+
							'<img src="../img/btn-icon/search.png"/>'+
							'<span>查询</span>'+
						'</button>'+
						'<button class="btn-green" id="division-closeBtn">'+
							'<img src="../img/btn-icon/close.png"/>'+
							'<span>关闭</span>'+
						'</button>'+
					'</div>'+
					'<table id="tableDivision"></table>'+
				'</div>'+
			'</div>'+
		'</div>'+
	'</div>'+
'</div>';
$('body').append(SelectDivision);
$("#tableDivision").bootstrapTable({ // 对应table标签的id
	url: DOMAIN+'/v1/division'+isLogin,
	method: 'get',
	cache: false,
	striped: true,
	pagination: true,
	pageSize: 5,
	pageNumber: 1,
	pageList: [5, 10],
	search: false,
	showColumns: false, 
	clickToSelect: true,
	queryParams: queryParams,
	smartDisplay: false,
	columns: [{
        checkbox: true
	}, {
		field: "id",
		title: "类型id",
		align: "center",
		valign: "middle",
		sortable: "true",
		visible: false
	}, {
		field: "code",
		title: "产地编码",
		align: "center",
		valign: "middle",
		sortable: "true"
	}, {
		field: "name",
		title: "产地名称",
		align: "center",
		valign: "middle",
		sortable: "true"
	}],	
	onDblClickRow: function (row) {
		selectDivision(row);
		//模拟关闭弹框
		  $('#SelectDivision').click();
	},
	formatNoMatches: function() {
		return '没有找到匹配的记录';
	}
});
function queryParams(params) {
	return params;
};

//查询
$("#division-selectBtn").click(function(){
	//新查询参数
	function queryParamNew(params) {
		var params = {};
		params.code = $("#dCode").val();
		params.name = $("#dName").val();
		return params;
	};
	var url =DOMAIN+'/v1/division'+isLogin;
	$('#tableDivision').bootstrapTable(
			'refreshOptions',
			{
				url: url,
				//查询参数
				queryParams: queryParamNew
			}
		);
	
})

//关闭
$("#division-closeBtn").click(function(){
	$('#SelectDivision').click();
})

//打开选择框时查询
$('#SelectDivision').on('shown.bs.modal', function () {
	$("#dCode").val("");
	$("#dName").val("");
	$('#tableDivision').bootstrapTable(
		'refreshOptions',
		{
			url: DOMAIN+'/v1/division'+isLogin,
		}
	);

})